package com.bestescortbedsystem.service.impl;

import com.bestescortbedsystem.dao.SesBedMessageDao;
import com.bestescortbedsystem.dao.SesUserFeedbackDao;
import com.bestescortbedsystem.entity.SesBedMessage;
import com.bestescortbedsystem.entity.SesUserFeedback;
import com.bestescortbedsystem.service.UserFeedBackService;
import com.bestescortbedsystem.util.FindDate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * ClassName: UserFeedBackServiceImpl
 * Package: com.bestescortbedsystem.service.impl
 *
 * @author: guanzepeng
 * @Date: 2021/3/2 20:49 星期二
 * @Description: 用户报修业务层
 */
@Service
public class UserFeedBackServiceImpl implements UserFeedBackService {

	@Resource
	private SesUserFeedbackDao sesUserFeedbackDao;

	@Resource
	private SesBedMessageDao sesBedMessageDao;

	/**
	 * 根据传入信息添加报修反馈
	 * @param sesUserFeedback 传入SesUserFeedback
	 * @param userId 传入用户ID
	 * @param bedmessageId 传入床位信息表ID
	 * @return 返回Boolean
	 */
	@Override
	public Boolean insertFeed(SesUserFeedback sesUserFeedback, Long userId, Long bedmessageId) {
		if(sesUserFeedback == null || userId == null || bedmessageId == null) {
			return false;
		}
		sesUserFeedback.setUserUserid(userId);
		SesBedMessage sesBedMessage = sesBedMessageDao.selectByPrimaryKey(bedmessageId);
		sesUserFeedback.setBedtypeid(sesBedMessage.getBedBedTypeid());
		sesUserFeedback.setUserfeedbackdate(FindDate.getDate());
		Boolean b = sesUserFeedbackDao.insertSelective(sesUserFeedback) == 1;
		return b;
	}
}
